#pragma once

#include "PictureViewer.h"
#include "HarrisOptionWindow.h"
#include "GaussOptionWindow.h"
#include "../Algorithm/algorithm.h"

namespace StereoCorrespond {

	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class MainWindow : public System::Windows::Forms::Form
	{
	private:
		String^ LeftFileName;
		String^ RightFileName;

		System::Void imageUpdated(bool left, bool right);
		System::Void processFeatures(Algorithm::Bitmap<float>* left, Algorithm::Bitmap<float>* right);
		
		GaussOptionWindow gaussWindow;
		HarrisOptionWindow harrisWindow;

	public:
		MainWindow(void)
		{
			InitializeComponent();

			LeftFileName = nullptr;
			RightFileName = nullptr;
		}

		MainWindow(String^ leftFileName, String^ rightFileName)
		{
			InitializeComponent();

			LeftFileName = leftFileName;
			RightFileName = rightFileName;
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~MainWindow()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::SplitContainer^  stereoSplitContainer;
	private: System::Windows::Forms::MenuStrip^  menuStrip;
	private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openLeftToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openRightToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;
	private: StereoCorrespond::PictureViewer^  rightPictureViewer;
	private: StereoCorrespond::PictureViewer^  leftPictureViewer;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem2;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem1;
	private: System::Windows::Forms::OpenFileDialog^  imageOpenFileDialog;
	private: System::Windows::Forms::ToolStripMenuItem^  algorithmToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  gaussFilterToolStripMenuItem;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem3;
	private: System::Windows::Forms::ToolStripMenuItem^  resetImagesToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  harrisFilterToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  hesseFilterToolStripMenuItem;
	private: System::Windows::Forms::Button^  previousButton;
	private: System::Windows::Forms::CheckBox^  logCheckBox1;
	private: System::Windows::Forms::CheckBox^  logCheckBox2;
	private: System::Windows::Forms::CheckBox^  justfeaturesCheckbox;
	private: System::Windows::Forms::Button^  nextButton;

	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->stereoSplitContainer = (gcnew System::Windows::Forms::SplitContainer());
			this->leftPictureViewer = (gcnew StereoCorrespond::PictureViewer());
			this->rightPictureViewer = (gcnew StereoCorrespond::PictureViewer());
			this->menuStrip = (gcnew System::Windows::Forms::MenuStrip());
			this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem2 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->openLeftToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openRightToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem3 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->resetImagesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->algorithmToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->gaussFilterToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->harrisFilterToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->hesseFilterToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->imageOpenFileDialog = (gcnew System::Windows::Forms::OpenFileDialog());
			this->previousButton = (gcnew System::Windows::Forms::Button());
			this->logCheckBox1 = (gcnew System::Windows::Forms::CheckBox());
			this->logCheckBox2 = (gcnew System::Windows::Forms::CheckBox());
			this->justfeaturesCheckbox = (gcnew System::Windows::Forms::CheckBox());
			this->nextButton = (gcnew System::Windows::Forms::Button());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->stereoSplitContainer))->BeginInit();
			this->stereoSplitContainer->Panel1->SuspendLayout();
			this->stereoSplitContainer->Panel2->SuspendLayout();
			this->stereoSplitContainer->SuspendLayout();
			this->menuStrip->SuspendLayout();
			this->SuspendLayout();
			// 
			// stereoSplitContainer
			// 
			this->stereoSplitContainer->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
				| System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->stereoSplitContainer->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
			this->stereoSplitContainer->Location = System::Drawing::Point(12, 27);
			this->stereoSplitContainer->Name = L"stereoSplitContainer";
			// 
			// stereoSplitContainer.Panel1
			// 
			this->stereoSplitContainer->Panel1->Controls->Add(this->leftPictureViewer);
			// 
			// stereoSplitContainer.Panel2
			// 
			this->stereoSplitContainer->Panel2->Controls->Add(this->rightPictureViewer);
			this->stereoSplitContainer->Size = System::Drawing::Size(760, 494);
			this->stereoSplitContainer->SplitterDistance = 378;
			this->stereoSplitContainer->TabIndex = 0;
			// 
			// leftPictureViewer
			// 
			this->leftPictureViewer->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
				| System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->leftPictureViewer->AutoScroll = true;
			this->leftPictureViewer->Image = nullptr;
			this->leftPictureViewer->Location = System::Drawing::Point(3, 3);
			this->leftPictureViewer->Name = L"leftPictureViewer";
			this->leftPictureViewer->Size = System::Drawing::Size(370, 486);
			this->leftPictureViewer->TabIndex = 0;
			this->leftPictureViewer->ZoomFactor = 1;
			// 
			// rightPictureViewer
			// 
			this->rightPictureViewer->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
				| System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->rightPictureViewer->AutoScroll = true;
			this->rightPictureViewer->Image = nullptr;
			this->rightPictureViewer->Location = System::Drawing::Point(3, 3);
			this->rightPictureViewer->Name = L"rightPictureViewer";
			this->rightPictureViewer->Size = System::Drawing::Size(370, 486);
			this->rightPictureViewer->TabIndex = 0;
			this->rightPictureViewer->ZoomFactor = 1;
			// 
			// menuStrip
			// 
			this->menuStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->fileToolStripMenuItem, 
				this->algorithmToolStripMenuItem});
			this->menuStrip->Location = System::Drawing::Point(0, 0);
			this->menuStrip->Name = L"menuStrip";
			this->menuStrip->Size = System::Drawing::Size(784, 24);
			this->menuStrip->TabIndex = 1;
			this->menuStrip->Text = L"menuStrip1";
			// 
			// fileToolStripMenuItem
			// 
			this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(8) {this->openToolStripMenuItem, 
				this->toolStripMenuItem2, this->openLeftToolStripMenuItem, this->openRightToolStripMenuItem, this->toolStripMenuItem3, this->resetImagesToolStripMenuItem, 
				this->toolStripMenuItem1, this->exitToolStripMenuItem});
			this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
			this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
			this->fileToolStripMenuItem->Text = L"File";
			// 
			// openToolStripMenuItem
			// 
			this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
			this->openToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::O));
			this->openToolStripMenuItem->Size = System::Drawing::Size(184, 22);
			this->openToolStripMenuItem->Text = L"Open...";
			this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::openToolStripMenuItem_Click);
			// 
			// toolStripMenuItem2
			// 
			this->toolStripMenuItem2->Name = L"toolStripMenuItem2";
			this->toolStripMenuItem2->Size = System::Drawing::Size(181, 6);
			// 
			// openLeftToolStripMenuItem
			// 
			this->openLeftToolStripMenuItem->Name = L"openLeftToolStripMenuItem";
			this->openLeftToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::L));
			this->openLeftToolStripMenuItem->Size = System::Drawing::Size(184, 22);
			this->openLeftToolStripMenuItem->Text = L"Open Left...";
			this->openLeftToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::openLeftToolStripMenuItem_Click);
			// 
			// openRightToolStripMenuItem
			// 
			this->openRightToolStripMenuItem->Name = L"openRightToolStripMenuItem";
			this->openRightToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::R));
			this->openRightToolStripMenuItem->Size = System::Drawing::Size(184, 22);
			this->openRightToolStripMenuItem->Text = L"Open Right...";
			this->openRightToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::openRightToolStripMenuItem_Click);
			// 
			// toolStripMenuItem3
			// 
			this->toolStripMenuItem3->Name = L"toolStripMenuItem3";
			this->toolStripMenuItem3->Size = System::Drawing::Size(181, 6);
			// 
			// resetImagesToolStripMenuItem
			// 
			this->resetImagesToolStripMenuItem->Name = L"resetImagesToolStripMenuItem";
			this->resetImagesToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::R));
			this->resetImagesToolStripMenuItem->Size = System::Drawing::Size(184, 22);
			this->resetImagesToolStripMenuItem->Text = L"Reset images";
			this->resetImagesToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::resetImagesToolStripMenuItem_Click);
			// 
			// toolStripMenuItem1
			// 
			this->toolStripMenuItem1->Name = L"toolStripMenuItem1";
			this->toolStripMenuItem1->Size = System::Drawing::Size(181, 6);
			// 
			// exitToolStripMenuItem
			// 
			this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
			this->exitToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::Q));
			this->exitToolStripMenuItem->Size = System::Drawing::Size(184, 22);
			this->exitToolStripMenuItem->Text = L"Exit";
			this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::exitToolStripMenuItem_Click);
			// 
			// algorithmToolStripMenuItem
			// 
			this->algorithmToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->gaussFilterToolStripMenuItem, 
				this->harrisFilterToolStripMenuItem, this->hesseFilterToolStripMenuItem});
			this->algorithmToolStripMenuItem->Name = L"algorithmToolStripMenuItem";
			this->algorithmToolStripMenuItem->Size = System::Drawing::Size(73, 20);
			this->algorithmToolStripMenuItem->Text = L"Algorithm";
			// 
			// gaussFilterToolStripMenuItem
			// 
			this->gaussFilterToolStripMenuItem->Name = L"gaussFilterToolStripMenuItem";
			this->gaussFilterToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::G));
			this->gaussFilterToolStripMenuItem->Size = System::Drawing::Size(171, 22);
			this->gaussFilterToolStripMenuItem->Text = L"Gauss filter";
			this->gaussFilterToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::gaussFilterToolStripMenuItem_Click);
			// 
			// harrisFilterToolStripMenuItem
			// 
			this->harrisFilterToolStripMenuItem->Name = L"harrisFilterToolStripMenuItem";
			this->harrisFilterToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::H));
			this->harrisFilterToolStripMenuItem->Size = System::Drawing::Size(171, 22);
			this->harrisFilterToolStripMenuItem->Text = L"Harris filter";
			this->harrisFilterToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::harrisFilterToolStripMenuItem_Click);
			// 
			// hesseFilterToolStripMenuItem
			// 
			this->hesseFilterToolStripMenuItem->Name = L"hesseFilterToolStripMenuItem";
			this->hesseFilterToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::E));
			this->hesseFilterToolStripMenuItem->Size = System::Drawing::Size(171, 22);
			this->hesseFilterToolStripMenuItem->Text = L"Hesse filter";
			this->hesseFilterToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainWindow::hesseFilterToolStripMenuItem_Click);
			// 
			// imageOpenFileDialog
			// 
			this->imageOpenFileDialog->Filter = L"Bitmap (*.bmp)|*.bmp|JPEG (*.jpg,*jpeg)|*.jpg;*.jpeg|TIF (*.tif)|*.tif|All files " 
				L"(*.*)|*.*";
			this->imageOpenFileDialog->Title = L"Open image";
			// 
			// previousButton
			// 
			this->previousButton->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
			this->previousButton->Location = System::Drawing::Point(311, 527);
			this->previousButton->Name = L"previousButton";
			this->previousButton->Size = System::Drawing::Size(75, 23);
			this->previousButton->TabIndex = 2;
			this->previousButton->Text = L"Previous";
			this->previousButton->UseVisualStyleBackColor = true;
			this->previousButton->Click += gcnew System::EventHandler(this, &MainWindow::previousButton_Click);
			// 
			// logCheckBox1
			// 
			this->logCheckBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
			this->logCheckBox1->AutoSize = true;
			this->logCheckBox1->Location = System::Drawing::Point(16, 531);
			this->logCheckBox1->Name = L"logCheckBox1";
			this->logCheckBox1->Size = System::Drawing::Size(106, 17);
			this->logCheckBox1->TabIndex = 3;
			this->logCheckBox1->Text = L"Use LoG on pic1";
			this->logCheckBox1->UseVisualStyleBackColor = true;
			//
			// justfeaturesCheckbox
			// 
			this->justfeaturesCheckbox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
			this->justfeaturesCheckbox->AutoSize = true;
			this->justfeaturesCheckbox->Location = System::Drawing::Point(156, 531);
			this->justfeaturesCheckbox->Name = L"justfeaturesCheckbox";
			this->justfeaturesCheckbox->Size = System::Drawing::Size(156, 17);
			this->justfeaturesCheckbox->TabIndex = 10;
			this->justfeaturesCheckbox->Text = L"Just features";
			this->justfeaturesCheckbox->UseVisualStyleBackColor = true;
			// 
			// logCheckBox2
			// 
			this->logCheckBox2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
			this->logCheckBox2->AutoSize = true;
			this->logCheckBox2->Location = System::Drawing::Point(662, 533);
			this->logCheckBox2->Name = L"logCheckBox2";
			this->logCheckBox2->Size = System::Drawing::Size(106, 17);
			this->logCheckBox2->TabIndex = 3;
			this->logCheckBox2->Text = L"Use LoG on pic2";
			this->logCheckBox2->UseVisualStyleBackColor = true;
			// 
			// nextButton
			// 
			this->nextButton->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
			this->nextButton->Location = System::Drawing::Point(398, 527);
			this->nextButton->Name = L"nextButton";
			this->nextButton->Size = System::Drawing::Size(75, 23);
			this->nextButton->TabIndex = 2;
			this->nextButton->Text = L"Next";
			this->nextButton->UseVisualStyleBackColor = true;
			this->nextButton->Click += gcnew System::EventHandler(this, &MainWindow::nextButton_Click);
			// 
			// MainWindow
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(784, 562);
			this->Controls->Add(this->logCheckBox2);
			this->Controls->Add(this->logCheckBox1);
			this->Controls->Add(this->justfeaturesCheckbox);
			this->Controls->Add(this->nextButton);
			this->Controls->Add(this->previousButton);
			this->Controls->Add(this->stereoSplitContainer);
			this->Controls->Add(this->menuStrip);
			this->MainMenuStrip = this->menuStrip;
			this->Name = L"MainWindow";
			this->Text = L"Stereo Correspondance";
			this->Load += gcnew System::EventHandler(this, &MainWindow::MainWindow_Load);
			this->stereoSplitContainer->Panel1->ResumeLayout(false);
			this->stereoSplitContainer->Panel2->ResumeLayout(false);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->stereoSplitContainer))->EndInit();
			this->stereoSplitContainer->ResumeLayout(false);
			this->menuStrip->ResumeLayout(false);
			this->menuStrip->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
		private: System::Void MainWindow_Load(System::Object^  sender, System::EventArgs^  e);
		private: System::Void openToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void openLeftToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void openRightToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void gaussFilterToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void resetImagesToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void harrisFilterToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void hesseFilterToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void previousButton_Click(System::Object^  sender, System::EventArgs^  e);
		private: System::Void nextButton_Click(System::Object^  sender, System::EventArgs^  e);
	};
}

